home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PB_212.ZIP / _LC.C < prev    next >
C/C++ Source or Header  |  1995-09-09  |  4KB  |  124 lines

  1. /***************************************************************************/
  2. /*** _LC.C                    Last caller list module for ProBoard v2.10 ***/
  3. /*** ─────────────────────────────────────────────────────────────────── ***/
  4. /*** This source file is distributed together with ProBoard v2.10, and   ***/
  5. /*** may be modified and redistributed, provided that this header is     ***/
  6. /*** not modified. When distributing the modified source code, make sure ***/
  7. /*** you add a comment block with your name and any changes you have     ***/
  8. /*** made. It would be appreciated if you send a copy of the modified    ***/
  9. /*** source code to the author (Philippe Leybaert)                       ***/
  10. /***                                                                     ***/
  11. /*** The author can be reached at FidoNet 2:291/1905                     ***/
  12. /***                           or CompuServe 70314,2021                  ***/
  13. /***                           or phl@innet.be                           ***/
  14. /***                           or in the FidoNet PROBOARD echo           ***/
  15. /***************************************************************************/
  16.  
  17. #include <pb_sdk.h>
  18.  
  19. char *months_short[] = { "???","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  20.  
  21. void
  22. main(int argc,char *argv[])
  23. {
  24.     bool aliases = FALSE;
  25.     int lc_num  = 10 ,  /* # Entries in list         */
  26.         lc_node =  0 ,  /* Node number to list       */
  27.         i ,
  28.         f ;             /* File handle for BINLOG.PB */
  29.  
  30.     char fname[80];
  31.     BINLOG *bl;
  32.     long cur_rec;
  33.  
  34.     strcpy(fname,SysPath);
  35.     strcat(fname,"BINLOG.PB");
  36.  
  37.     for(i=1;i<argc;i++)
  38.     {
  39.         if(isdigit(argv[i][0])) lc_num = atoi(argv[i]);
  40.  
  41.         if(argv[i][0] == '/')
  42.         {
  43.             switch(argv[i][1])
  44.             {
  45.                 case 'N': if(strlen(argv[i]) > 3) lc_node = atoi(&argv[i][3]);
  46.                           break;
  47.                 case 'H': aliases = TRUE;
  48.                           break;
  49.             }
  50.         }
  51.     }
  52.  
  53.     f = open(fname,O_RDONLY | O_DENYNONE);
  54.  
  55.     if(f < 0) return;
  56.  
  57.     bl = malloc( lc_num * sizeof(BINLOG));
  58.  
  59.     cur_rec = l_div(filelength(f) , sizeof(BINLOG));
  60.  
  61.     if(cur_rec >= 1) cur_rec--;
  62.  
  63.     for(i = 0 ; i < lc_num ; cur_rec--)
  64.     {
  65.         lseek(f , l_mul(cur_rec,sizeof(BINLOG)) , SEEK_SET);
  66.  
  67.         if(read(f , &bl[i] , sizeof(BINLOG)) != sizeof(BINLOG)) break;
  68.  
  69.         if(!bl[i].baud) continue;
  70.  
  71.         if(bl[i].uflags & UFLAG_HIDDEN) continue;
  72.  
  73.         if(lc_node && lc_node != bl[i].node) continue;
  74.  
  75.         i++;
  76.     }
  77.  
  78.     close(f);
  79.  
  80.     lc_num = i;
  81.  
  82.     EnableStop();
  83.  
  84.     InitLineCounter();
  85.  
  86.     printf("\n\f\7╓────────────────────────────────╥────────╥──────────────────────╥────╥───────╖\n"
  87.            "║\6   Name                         \7║\6  Date  \7║\6        Online        \7║\6 N# \7║\6 Speed \7║\n"
  88.            "╟────────────────────────────────╫────────╫──────────────────────╫────╫───────╢\n");
  89.  
  90.     LineCounter();
  91.     LineCounter();
  92.     LineCounter();
  93.  
  94.     for(i = 0 ; i<lc_num ; i++)
  95.     {
  96.       int onlinetime = 60 * (bl[i].timeOut[0] - bl[i].timeIn[0])
  97.                           + (bl[i].timeOut[1] - bl[i].timeIn[1]);
  98.  
  99.       if(onlinetime < 0) onlinetime += 60*24;
  100.  
  101.       if(Stopped()) break;
  102.  
  103.       if(bl[i].alias[0] == '\0')
  104.          strcpy(bl[i].alias,bl[i].name);
  105.  
  106.       printf("║\3 %-31.31s\7║\5 %02d %3.3s \7║\1 %02d:%02d \7-\1 %02d:%02d \7(\2%3d'\7) ║\1%3d \7║\3 %5ld \7║\n",
  107.             (aliases ? bl[i].alias:bl[i].name),bl[i].date[0],months_short[bl[i].date[1]],
  108.             bl[i].timeIn[0],bl[i].timeIn[1],bl[i].timeOut[0],bl[i].timeOut[1],onlinetime,bl[i].node,bl[i].baud);
  109.  
  110.       if(!LineCounter()) break;
  111.     }
  112.  
  113.     if(!Stopped())
  114.       {
  115.        if(LineCounter() && LineCounter() && LineCounter())
  116.          {
  117.           printf("╙────────────────────────────────╨────────╨──────────────────────╨────╨───────╜\n\n"
  118.                  " Press \3[Enter]\7 to continue.\t");
  119.          }
  120.       }
  121.  
  122.     free(bl);
  123. }
  124.